//
//  HomeActivityRecord.swift
//  DaRings
//
//  Created by 尹琼 on 2022/10/28.
//

import UIKit
import HandyJSON


public class HomeActivityModel {
    
    public class Record {
        
        public var target: Double
        public var current: Double
        public var unit: String
        
        public var progress: CGFloat {
            
            if target == 0 {
                return 0.01
            }
            return CGFloat(current)/CGFloat(target)
        }
        
        public init(target: Double, current: Double, unit: String) {
            self.target = target
            self.current = current
            self.unit = unit
        }
        public var title: String {
            
            return current.normalTitle
        }
        public var intTitle: String {
            
            return Int(current).normalTitle
        }
        
        public var targetTitle: String {
            return  "\(target.normalTitle) \(unit)"
            
        }
        
        public var intTargetTitle: String {
            return  "\(Int(target).normalTitle) \(unit)"
            
        }
        
    }
    
    public var date: String = ""
    public var step: Record?
    public var calories: Record?
    public var duration: Record?
    
    public init(date: String, step: Record, calories: Record, duration: Record) {
        self.date = date
        self.step = step
        self.calories = calories
        self.duration = duration
        
    }
    
  
}
